<?php
$css = "#topSeven .box-content{min-height:293px}";
cs()->registerCss("productivity", $css);
?>
<div class="box span5 noMargin box-order" ontablet="span12" ondesktop="span5" id="topSeven">
    <div class="box-header">
        <div class="row-fluid">
            <div class="span6">
                <h2>Top 7 popular services</h2>
            </div>
        </div>
    </div>
    <div class="box-content">
        <div class="todo">
            <form>
                <?php if ($this->isAdmin): ?>
                    <?php
                    echo CHtml::dropDownList("biz_top7", $this->selectBizUkey, Users::getAllBussiness(TRUE), array(
                        "onchange" => "selectBizTopSeven($(this))",
                        "data-rel" => "chosen",
                    ));
                    ?>
<?php endif; ?>
            </form>
            <ul class="todo-list ui-sortable">
                <?php $color = array('label-first', 'label-second', 'label-third', 'label-fourth', 'label-fifth', 'label-fifth', 'label-fifth') ?>
<?php foreach ($popular_sv as $key => $sv): ?>
                    <li>
                        <span class="todo-actions" style="opacity: 1;"></span>
                        <a href="<?php echo $sv->editUrl ?>">
                            <img src="<?php echo $sv->getImageService50($sv->avatar); ?>">
                        </a>&nbsp;
                        <span class="desc">
                            <?php if ($this->isStaff): ?>
                                <?php echo htmlentities($sv->s_name, ENT_QUOTES) ?>
                                <?php else: ?>
                                <a href="<?php echo $sv->editUrl ?>">
                                <?php echo htmlentities($sv->s_name, ENT_QUOTES) ?>
                                </a>
    <?php endif; ?>
                            <span class="muted"><b><?php echo $sv->appointCount ?></b>&nbsp;<i>reservations</i></span>
                        </span>
                        <span class="label <?php echo $color[$key] ?>"><?php echo $key + 1 ?></span>
                    </li>
<?php endforeach; ?>
            </ul>
        </div>	
    </div>
</div>
<?php if ($this->isAdmin): ?>
    <script>
        $("[data-rel='chosen']").chosen();
        function selectBizTopSeven(el)
        {
            $.ajax({
                url: '<?php echo Yii::app()->createUrl('site/_reloadTopSeven') ?>',
                type: 'POST',
                data: {
                    biz_ukey: el.val()
                },
                success: function(response) {
                    $('#topSeven').remove();
                    $("#_topSeven").before(response);
                }
            });
        }
    </script>
<?php endif; ?>